/*
 * @Description  :
 * @Version      : 0.1
 * @Company      : V-Think Development Team
 * @Author       : KiraVerSace@yeah.net
 * @Date         : 2022-11-22 18:56:52
 * @LastEditTime : 2023-07-17 16:05:59
 */
#ifndef __BOOT_LOADER_H__
#define __BOOT_LOADER_H__

#include <xCommon.h>

typedef struct
{
    uint8_t  firmwarePath[512];
    uint32_t firmwareLength;

    uint32_t startRangeIndex;   // 参数起始和结束Range: bytes=0-2047
    uint32_t endRangeIndex;

    uint32_t firmwareRxCount;   // 接收固件的大小计数

    uint32_t crc32Value;
}__attribute__((packed)) OTAParameterT;
extern OTAParameterT otaParameter;

extern void bootLoaderInit(void);

extern bool bootLoaderCheckApplicationExist(void);
extern void bootLoaderJumpToApplication(void);

extern bool bootLoaderEraseFlash(void);
extern bool bootLoaderWriteFlash(const uint32_t address, const uint8_t pValue[], const uint32_t length);

extern uint32_t bootLoaderCRC32Verify(const uint32_t length);
extern bool     bootLoaderPraseFirmwarePath(const char *url, const uint16_t length);


#endif

